//
//  TBCReading.m
//  待定
//
//  Created by BoyaLee on 15/11/5.
//  Copyright © 2015年 BoyaLee. All rights reserved.
//

#import "TBCReading.h"

@interface TBCReading ()

@property (strong, nonatomic) NSMutableArray *arrayList;
@property (strong, nonatomic) NSMutableArray *arrayCarousel;

@end

@implementation TBCReading

+ (instancetype)shareReading {
    
    static TBCReading *reading = nil;
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        reading = [[TBCReading alloc] init];
        
    });
    
    return reading;
    
}

- (void)getAllArray:(id)responceObject {
    
    NSDictionary *dic = responceObject;
    
    self.arrayList = [NSMutableArray arrayWithCapacity:0];
    self.arrayCarousel = [NSMutableArray arrayWithCapacity:0];
    
    // list解析
    NSArray *listArray = [[dic objectForKey:@"data"] objectForKey:@"list"];
    for (NSDictionary *dictionary in listArray) {
        
        TBCReading *readingList = [[TBCReading alloc] init];
        [readingList setValuesForKeysWithDictionary:dictionary];
        [self.arrayList addObject:readingList];

    }
    
    // carousel解析
    NSArray *carouselArray = [[dic objectForKey:@"data"] objectForKey:@"carousel"];
    for (NSDictionary *dictionary in carouselArray) {
        
        TBCReading *readingCarousel = [[TBCReading alloc] init];
        readingCarousel.img = [dictionary objectForKey:@"img"];
        readingCarousel.url = [dictionary objectForKey:@"url"];
        [self.arrayCarousel addObject:readingCarousel];
        
    }
    
    [self.delegate sendAllArray:self.arrayList Array:self.arrayCarousel];
    
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
}

@end
